|
|
|
|
|
|
|
A table-type recordset is a direct link to a table in the database. Because all the data in a database is stored in tables, this recordset type is the most direct way to access the data. Because tables also are the only recordset type that supports indexes, searching a table for a specific record can be much quicker than searching a dynaset or snapshot. |
|
|
|
|
|
|
|
|
When using tables, data is retrieved or modified one table at a time, one record at a time. This provides very fine control over data manipulation, but it doesn't allow you to access multiple tables at the same time. Unfortunately, you cannot set filters on a table to limit the number of records being returned. |
|
|
|
|
|
|
|
|
To open a table for use, you need to define a Recordset object and then use the Open method to access the table. You also need to set the recordset type to specify that you want a table-type recordset. The adCmdTable constant in the method's parameters opens a table recordset. The following listing shows how to open a table using an already opened connection named adDbCon1. |
|
|
|
|
|
|
|
|
Dim MyTble As Recordset
myTble.Open Titles, adDbCon1,,,adCmdTable |
|
|
|
|
|
|
|
|
A query is a grouping of data from one or more tables in a database. This data is selected with a SQL statement that usually contains field names filters. Queries address the records present in the base tables at the time the query was created. They allow users to make changes in the data and store it back into the database. However, queries don't automatically reflect additions or deletions of records made by other code, users, or applications after the query was created. |
|
|
|
|
|
|
|
|
Using queries allows you to do the following: |
|
|
|
 |
|
|
|
|
Join data from multiple tables |
|
|
|
 |
|
|
|
|
Limit the number of fields or records retrieved from the database |
|
|
|
 |
|
|
|
|
Use filters and sort-order properties to change the data view |
|
|
|
|
|
|
|
|
Queries also have a limitation that you should be aware of: |
|
|
|
 |
|
|
|
|
The query won't automatically reflect any changes made to the data in the base tables. You have to requery it. |
|
|
|
|
|
|
|
|
Opening a query is very similar to opening a table. The only real difference is the parameter that specifies the type of recordset to open. The adCmdText parameter creates a query when used in the Open method. However, the most important part of the Open method when dealing with queries is the SQL statement that defines the records to be |
|
|
|
|
|